<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>编辑角色</title>
<link href="/widget/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"  type="text/css"/>
 {cssjs}
<link href="/res/css/inside_page.css" rel="stylesheet"  type="text/css"/>
<style>
    li{float:left;width:70px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin:.2rem 0;}
    .che_input{float:left;}
</style>
</head>

<body>
<div class="container-fluid larry-wrapper">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" method="post" data-dotype="a" action="./?t=select_accept">
                <table class="layui-table">
                  <colgroup>
                    <col width="150">
                    <col width="150">
                    <col width="200">
                    <col>
                  </colgroup>
                  <thead>
                    <tr style="background-color:white;">
                      <th><div class="check_box che_all" title="全选">
                            <input type="checkbox" id="_checkall" onclick="checkall(this.checked)" style="display:block;"> 
                           <label class="check" for="" onclick="$('#_checkall').click()">  
                                <i class="iconfont" id="#icon-duihao2"></i>
                            </label><a style="float:left;margin:-17px 0 0 16px">全选</a>
                        </div></th>
                      <th style="width:950px;"><input type="text" placeholder="用户名" id="sname" value="{sname}" name="acceptname" autocomplete="off" class="layui-input" style="width:15%;"><input type="button" lay-submit class="layui-btn" lay-filter="search" id="btn_search" value="查找" style="float:left;margin:-37px 0 0 200px"/></th>
                    </tr>
                    <input type="hidden" name="sname" id="sname" />
                    <tr>
                      <th>部门</th>
                      <th style="width:950px;">用户列表</th>
                    </tr> 
                  </thead>
                  <tbody>
                    <!-- START list -->
                    <tr>
                      <td>
                        <div class="check_box che_all" title="同部门全选">
                            <input type="checkbox" class="dept_check" onclick="" style="display:block;"> 
                           <label class="check" for="" onclick="">  
                                <i class="iconfont" id="#icon-duihao2"></i>
                            </label><a style="float:left;margin:-17px 0 0 16px">{deptname}</a>
                        </div></td>
                      <td>
                      <!-- START rp -->
                      <li><div class="check_box che_input">
                            <input id="{id}" name="check" _name="{truename}" type="checkbox" class="everyvb" style="display:block;">  
                            <label class="check checkchild" for="{id}">  
                                <i class="iconfont"></i>
                            </label><a style="float:left;margin:-17px 0 0 16px">{truename}</a> 
                          </div>
                          <input type="hidden" name="accept_id" id="accept_id" value="{id}"/>
                      </li>
                      <!-- END rp -->
                      </td>
                    </tr>
                    <!-- END list -->
                  </tbody>
                </table> 
                <input class="layui-btn layui-btn-danger" style="margin:0 0 0 580px;" onclick="getAllcheck();" value="确认" type="button"/>
                </form>
            </section>
        </div>
    </div>
</div>
   <script type="text/javascript">
   var userid='{uids}';
   if(userid!=""){
   var useridarr=userid.split(',');
    for(var i = 0;i<useridarr.length;i++){
        $("#"+useridarr[i]).prop("checked",true);
    }
   }
    function checkall(v){
        $(":checkbox").each(function(){
            this.checked=v;
        })
    };
    $(".dept_check").each(function(){
        $(this).on("click",function(){
            if($(this).prop("checked")){
                $(this).parent().parent().next().find(":checkbox").prop("checked", true);
            }else{
                $(this).parent().parent().next().find(":checkbox").prop("checked", false);
                $("#_checkall").prop("checked", false);
            }
        });
    });
    $(".checkchild").on("click",function(){
        $("#_checkall").prop("checked", false);
    });
    $("._ytt").on("click",function(){
        if($(this).find(".everyvb").prop("checked")){
            $(this).find(".everyvb").prop("checked", false);
        }else{
            $(this).find(".everyvb").prop("checked", true);
        }
    }); 
    $().ready(function(){
           $("#btn_search").on("click",function(){   
                var nm=$("#sname").val();
                location.href="?t=select_accept&sname="+nm;
            }); 
    });
    
    function getAllcheck(){
        var allid="";
        $(".everyvb").each(function(){
            if($(this).prop("checked")){
                allid+=$(this).attr("id")+",";
            }
        });
        allid=allid.substring(0,allid.length-1);
        $('#accept_id').val(allid); 
        $.post("/srv/sdo.php", {tpl:"edit_attend_free",uids:allid}, function (d, e) {  
            if(d=="ok"){
                layer.msg('修改完成');
            }
        });
    }
    </script>
</body>
</html>